package kortsoft.culcon.manager;

import java.util.HashSet;


import kortsoft.culcon.model.Advance;
import kortsoft.culcon.model.Culture;
import kortsoft.culcon.model.CultureType;
import kortsoft.culcon.model.Player;

public class CultureManager extends Manager{
	
	public Culture createCulture(CultureType cultureType, Player player){
		Culture culture = new Culture();
		culture.setCultureType(cultureType);
		culture.setPlayer(player);
		culture.setAdvances(new HashSet<Advance>());
		culture.getAdvances().add(cultureType.getStartingAdvance());
		return saveCulture(culture);		
	}

	private Culture saveCulture(Culture culture) {		
		Integer cultureCode = (Integer) getSession().save(culture);		
		return (Culture) getSession().get(Culture.class,cultureCode);
	}



}
